package edu.pku.sei.modeler.figures.anchor;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;

import edu.pku.sei.modeler.figures.LifelineFigure;

public class LifelineTargetAnchor extends MessageTargetAnchor {

	public LifelineTargetAnchor(IFigure figure) {
		super(figure);
	}
	
	public Point getLocation(Point ref) {
		Point pt = super.getLocation(ref);
		
		Rectangle rectangle = Rectangle.SINGLETON;
		rectangle.setBounds(getOwner().getBounds());
		getOwner().translateToAbsolute(rectangle);
		if (pt.y - rectangle.y > LifelineFigure.HEAD_HEIGHT)
			pt.x = rectangle.x + rectangle.width / 2;
		return pt;
	}
}
